package com.zb.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.zb.dao.BaseDao;
import com.zb.dao.CarDao;
import com.zb.entity.Car;

public class CarDaoImpl implements CarDao{
	private BaseDao db=new BaseDao();
	public void addCar(Car c) {
		String sql="INSERT INTO car VALUES(NULL,?,?,?)";
		db.update(sql,c.getCarNum(),c.getCarName(),c.getCarAir());
		db.close();
	}
	public int getMax() {
		String sql="SELECT MAX(id) FROM car";
		ResultSet rs=db.query(sql);
		int max=0;
		try {
			if(rs.next()) {
				max=rs.getInt(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			db.close();
		}
		return max;
	}
}
